#include <linux/module.h>
#include <linux/fs.h>

static void myfs_kill_super(struct super_block *sb) {
    // 可以在这里进行清理和释放资源的操作
    pr_info("Unmounting My Filesystem\n");

    // 调用基本的 kill_block 函数来卸载文件系统
    kill_block_super(sb);
}

static struct file_system_type myfs_type = {
    .name = "myfs",
    .mount = myfs_mount,
    .kill_sb = myfs_kill_super,
};

static int __init myfs_init(void) {
    int ret = register_filesystem(&myfs_type);
    if (ret == 0) {
        pr_info("My Filesystem registered.\n");
    } else {
        pr_err("Failed to register My Filesystem: %d\n", ret);
    }
    return ret;
}

static void __exit myfs_exit(void) {
    int ret = unregister_filesystem(&myfs_type);
    if (ret == 0) {
        pr_info("My Filesystem unregistered\n");
    } else {
        pr_err("Failed to unregister My Filesystem: %d\n", ret);
    }
}

module_init(myfs_init);
module_exit(myfs_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Your Name");
MODULE_DESCRIPTION("Simple Filesystem Module");